package com.example.demo.jsonplaceholder;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.List;

//添加注解，指明客户端名称和调用API服务的网站
@FeignClient(value = "jsonplaceholder", url = "https://jsonplaceholder.typicode.com")
public interface JSONPlaceHolderClient {

//    getPosts方法
    @GetMapping("/posts")
    List<Post> getPosts();

//    getPost方法：根据postId获得post
    @GetMapping("/posts/{postId}")
    Post getPost(@PathVariable("postId") Integer postId);


}
